<?php
  class Configuracoes {
    private $appID;
    private $appSecret;
    private $canvasURL;
    private $permissions;
    private $authenticationCode;
    private $accessToken;
    private $userID;

    function __construct($aAppID, $aAppSecret, $aCanvasURL, $aPermissios, $aAuthenticationCode, $aAccessToken, $aUserID) {
      $this->appID = $aAppID;
      $this->appSecret = $aAppSecret;
      $this->canvasURL = $aCanvasURL;
      $this->permissions = $aPermissios;
      $this->authenticationCode = $aAuthenticationCode;
      $this->accessToken = $aAccessToken;
      $this->userID = $aUserID;
    }

    public function getAppID() {
      return $this->appID;
    }

    public function setAppID($aAppID) {
      $this->appID = $aAppID;
    }

    public function getAppSecret() {
      return $this->appSecret;
    }

    public function setSecretID($aSecretID) {
      $this->appSecret = $aSecretID;
    }

    public function getCanvasURL() {
      return $this->canvasURL;
    }

    public function setCanvasURL($aCanvasURL) {
      $this->canvasURL = $aCanvasURL;
    }

    public function getPermissions() {
      return $this->permissions;
    }

    public function setPermissions($aPermissions) {
      $this->permissions = $aPermissions;
    }

    public function getAuthenticationCode() {
      return $this->authenticationCode;
    }

    public function setAuthenticationCode($aAuthenticationCode) {
      $this->authenticationCode = $aAuthenticationCode;
    }

    public function getAccessToken() {
      return $this->accessToken;
    }

    public function setAccessToken($aAccessToken) {
      $this->accessToken = $aAccessToken;
    }

    public function getUserID() {
      return $this->userID;
    }

    public function setUserID($aUserID) {
      $this->userID = $aUserID;
    }

    public function salvar($aNomeArquivo) {
      file_put_contents($aNomeArquivo, serialize($this));
    }
    
    public static function carregar($aNomeArquivo) {
      return unserialize(file_get_contents($aNomeArquivo));
    }
  }

  // Carregando valores padrão (meu userID é fixo mesmo)
  $configuracoes = new Configuracoes("","","","","","","10152132637511924");

  if (file_exists("./configuracoes.json")) {
    unset($configuracoes);
    $configuracoes = Configuracoes::carregar("./configuracoes.json");
  } else {
    $configuracoes->salvar("./configuracoes.json");
  }
?>